

# setup to allow the module to be imported from the same directory
#   the script is in
import sys
import os
filename = sys.argv[2]
filepath = os.path.dirname(filename)
sys.path.insert(0,filepath)
import OLib as MyLib

import Blender
import Blender.Mathutils
from Blender.Mathutils import *
from Blender import *

image = MyLib.Image('MyScene')
image.lookFrom(3.5,3,15)
image.lookAt(3.5,3,0)

image.addText(text='Cylinders with SubSurfaces',width=5,height=1,
			location=[5,6.5,0],align='MIDDLE')

			
#image.addCylinder(p1=[0,0,0],p2=[1,1,1],color=[0,1,0],verts=6)			

image.addSphere(location=[2,2,0],color=[0,1,0],diameter=1)
	
image.addBlock(c1=[0,0,0],c2=[1,2,3],color=[0,1,1])
	
xList = range(0,10)
vertList = [3,4,5,6,7,8,9,10,11,12]

image.addText(text='Num Verts =',width=10,height=0.4,
			location=[-0.25,-0.75,0],align='RIGHT',
			color=[1.0,0.0,0.0])
ob=image.addText(text='Num SubSurfaces', width=20,height=0.4,
            location=[-1,3,0],align='MIDDLE',
			color=[0.0,1.0,0.0])
ob.setEuler(0,0,90*3.1415/180.0)
for i in range(0,len(vertList)):
	verts = vertList[i]
	image.addText(text=str(verts),width=1,height=0.4,
				location=[xList[i],-0.75,0],align='MIDDLE',
				color=[1.0,0.0,0.0])
	for subSurfLevel in range(0,7):
		# add a UVsphere
		cylinderOb = image.addCylinder(diameter=0.6,verts=verts, 
			p1=[xList[i],subSurfLevel,0],p2=[xList[i],subSurfLevel,1.0],
			color=[1,0,1])
		mods = cylinderOb.modifiers
		mod = mods.append(Modifier.Types.SUBSURF) 		# add a new subsurf modifier
		mod[Modifier.Settings.LEVELS] = subSurfLevel	# set subsurf subdivision level
		mod[Modifier.Settings.TYPES]  = 0
		image.addText(text=str(subSurfLevel),width=1,height=0.4,
		location=[-0.5,subSurfLevel-0.2,0],align='RIGHT',
		color=[0.0,1.0,0.0])			
	
image.save(filepath+'\\images\\'+'test003_Cyliner.jpg')
